<template>
  <div class="collect-page">
    <van-nav-bar title="我的收藏" class="collectTop" left-arrow @click-left="regFn" />
    <div class="kong"></div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <CollectPage v-for="item in list"
      :key="item.id"
      :item="item"></CollectPage>
    </van-list>
  </div>
</template>

<script>
import CollectPage from "@/components/CollectPage.vue";
import { getCollect } from "@/api/user";
export default {
  components: {
    CollectPage,
  },
  methods: {
    async onLoad(){
      const res = await getCollect()
    console.log(res )
    if(res.body){
      this.list = res.body
    }else{
      this.$router.push('/login')
    }
    // this.loading = true
    },
    regFn() {
      this.$router.back();
    },
  },
  data() {
    return {
      list: [],
       loading: false,
      finished: false
    };
  },
};
</script>

<style scoped>
.collectTop{
  position: fixed;
  width: 100%;
}
.kong{
  width: 100%;
  height: 50px;
}
</style>
